<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>短信发送历史</title>
	<%@ include file="/page/common/common.jsp" %>	
	
    <script type="text/javascript">
    jQuery(function($){
		$('#gridTable').datagrid({
			title:'短信发送历史列表', //标题
			method:'post',			
			singleSelect:true, //多选
			height:360, //高度
			fitColumns: true, //自动调整各列，用了这个属性，下面各列的宽度值就只是一个比例。
			striped: true, //奇偶行颜色不同
			collapsible:true,//可折叠
			url:"${ctx}/sys/smshistory/query.sys", //数据来源
			sortName: 'smsHistoryId', //排序的列
			sortOrder: 'desc', //倒序
			remoteSort: true, //服务器端排序
			idField:'smsHistoryId', //主键字段
			queryParams:{}, //查询条件
			pagination:true, //显示分页
			rownumbers:true, //显示行号
			columns:[[
				
				{field:'smsHistoryId',title:'ID',width:35,
					formatter:function(value,row,index){
						return '<a href="javascript:void(0);" onclick="window.parent.setmain(\''+row.passName+'-短信详情\',\'${ctx}/sys/smshistory/queryDetail.sys?smsHistoryId='+row.smsHistoryId+'\');">'+row.smsHistoryId+'<a>';
					}					
				},
				{field:'sendTime',title:'发送日期',width:30},
				{field:'passName',title:'旅客姓名',width:25},
				{field:'flightNo',title:'航班号',width:25},
				{field:'flightTime',title:'起飞时间',width:25},
				{field:'pnr',title:'PNR',width:20},
				{field:'tktNo',title:'票号',width:30},
				{field:'phone',title:'手机号码',width:30},
				{field:'status',title:'发送状态',width:30,
					formatter:function(value,row,index){
						switch(row.status){
							case ${constant.SMS_SEND_ING}:
								return '<span class="status-info">发送中</span>';
								break;
							case ${constant.SMS_SEND_SUCCESS}:
								return '<span class="status-success">发送成功</span>';
								break;
							case ${constant.SMS_SEND_FAIL}:
								return '<span class="status-important">发送失败</span>';
								break;
							case ${constant.SMS_SEND_OVER}:
								return '<span class="status-warning">发送终止</span>';
								break
							default:
								return '未知';
								break;
						}
					}
				}
			]],
			
			onLoadSuccess:function(){
				$('#gridTable').datagrid('clearSelections'); //一定要加上这一句，要不然datagrid会记住之前的选择状态，删除时会出问题
			}
		});		
		
		
	});
   
    
   
    
    /** 表格查询 */
	function searchInfo(){
		var fields =$('#queryForm').serializeArray(); //自动序列化表单元素为JSON对象数据格式如下
		// [ 
		//     {name: 'firstname', value: 'Hello'}, 
		//     {name: 'lastname', value: 'World'},
		//     {name: 'alias'}, // this one was empty
  		// ]
		var params={};
		$.each( fields, function(i, field){//设置查询参数
			params[field.name] = field.value; 
		});
		$('#gridTable').datagrid('reload',params); //设置好查询参数 reload 一下就可以了
	}
	/** 清空查询条件 */
	function clearForm(){
		$('#queryForm').form('clear');
	}

	</script>	
  </head>
  
  <body>
    <form id="queryForm" class="qform">
		<table class="qtable" width="100%">
			<tr>
				<td class="qtd">开始时间：<input class="txt easyui-datebox" name="beginDate" style="width: 100px;"></td>
				<td class="qtd">结束时间：<input class="txt easyui-datebox" name="endDate" style="width: 100px;"></td>
				<td class="qtd">航&nbsp;班&nbsp;号：<input class="txt" name="flightNo" style="width: 100px;"></td>
				<td class="qtd">PNR：<input class="txt" name="pnr" style="width: 100px;"></td>
			</tr>
			<tr>
				<td class="qtd">电子票号：<input class="txt" name="tktNo" style="width: 100px;"></td>
				<td class="qtd">旅客姓名：<input class="txt" name="passName" style="width: 100px;"></td>
				<td class="qtd">发送状态：<select name="status" style="width: 100px;">
						<option value="-1">全部</option>
						<option value="0">发送中</option>
						<option value="1">发送成功</option>
						<option value="2">发送失败</option>
						<option value="3">终止</option>
					</select>
				</td>
				<td class="qtd">&nbsp;</td>
			</tr>
			<tr>
				<td class="qtd" align="center" colspan="4">
					<a href="#" onclick="clearForm();" class="easyui-linkbutton">清空</a>
					<a href="#" onclick="searchInfo();" class="easyui-linkbutton" iconCls="icon-search">查询</a>
				</td>
			</tr>
		</table>
	</form>
	<div class="griddiv">
		<table id="gridTable"></table>
	</div>
	<div id="MyPopWindow" modal="true" shadow="false" minimizable="false" cache="false" maximizable="false" collapsible="false" resizable="false" style="margin: 0px;padding: 0px;overflow: auto;"></div>
  </body>
</html>
